package com.atwisdom.star;

import com.atwisdom.star.dcs.Thread.*;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Configuration
public class DataCollectListener implements ApplicationListener<ApplicationReadyEvent> {
//    @Resource
//    private DataCollectionThread dataCollectionThread;
//
    @Resource
    private RealTimeInfoMinuteTread realTimeInfoMinuteTread;
    @Resource
    private RealTimeInfoHourTread realTimeInfoHourTread;

    @Resource
    private RealTimeInfoDayTread realTimeInfoDayTread;
    @Resource
    private RealTimeInfoMonthTread realTimeInfoMonthTread;

    @Resource
    private RealTimeInfoYearTread realTimeInfoYearTread;
//
//    @Resource
//    private ClearTempDataTread clearTempDataTread;


    @Override
    public void onApplicationEvent(ApplicationReadyEvent event) {
        System.out.println("ApplicationReadyEvent init data collection listener thread.");
        try {
//            从力控获取采集数据到临时表、和历史表中线程
            /*Thread thread=new Thread(dataCollectionThread);
            thread.start();*/

            //按分钟统计线程
//            Thread minuteThread=new Thread(realTimeInfoMinuteTread);
//            minuteThread.start();
//
//            //按小时统计线程
//            Thread hourThread=new Thread(realTimeInfoHourTread);
//            hourThread.start();
//
//            //按天统计线程
//            Thread dayThread=new Thread(realTimeInfoDayTread);
//            dayThread.start();
//
//            //按月统计线程
//            Thread monthThread=new Thread(realTimeInfoMonthTread);
//            monthThread.start();
//
//            //按年统计线程
//            Thread yearThread=new Thread(realTimeInfoYearTread);
//            yearThread.start();

//            //清理临时表数据
//            Thread clearThread=new Thread(clearTempDataTread);
//            clearThread.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("ApplicationReadyEvent init data collection listener thread finished.");
    }
}
